﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using PermitsAndVisasLeadsSyncher.Model;
using PermitsAndVisasLeadsSyncher.Helpers;

namespace PermitsAndVisasLeadsSyncher.Data_Gateway
{
    internal class CountryGateway
    {
        public List<Country> FillListOfCountriesPresentInCRMDatabase()
        {
            List<Country> countries = new List<Country>();
            DataTable dt = new DataTable();
            dt = DBHelper.GetDataTable(QueryProvider.MakeSQLQueryToFetchCountryList());
            if (dt.Rows.Count <= 0)
            {
                return countries;
            }
            foreach (DataRow dataRow in (InternalDataCollectionBase)dt.Rows)
            {
                countries.Add(new Country()
                {
                    Id = dataRow["Country_ID"].ToString(),
                    Name = dataRow["Country_Name"].ToString()
                });
            }
            return countries;
        }
    }
}
